<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/head.jsp"%>
<%@ include file="/jsp/jslib.jsp"%>
</head>

<body>
<%@ include file="/jsp/banner.jsp"%>
<div class="am-cf admin-main">
    <%@ include file="/jsp/menu.jsp"%>
	
	<!-- content start -->
	<div class="admin-content">
		<div class="admin-content-body">
		
		<!-- ***** 分离出去 动态加载 start ***** -->
		
		<div class="admin-content-body">
		    <div class="am-cf am-padding am-padding-bottom-0">
		        <div class="am-fl am-cf">
		            <strong class="am-text-primary am-text-lg"> 修改密码 </strong>
		        </div>
		    </div>
		    
		    <hr>
		    
            <form action="${ctx}/self/updatepassword" method="post" onsubmit="return toVaild()" class="am-form">
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 原密码 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <input id="password" name="password" type="text" class="am-input-sm" required>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 新密码 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <input id="newPassword" name="newPassword" type="text" class="am-input-sm" required>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 新密码 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <input id="newPassword2" name="newPassword2" type="text" class="am-input-sm" required>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
		    
			    <div class="am-margin">
			        <button type="submit" class="am-btn am-btn-primary am-btn-sm am-margin-sm"> 保 存 </button>
			        <button type="button" class="am-btn am-btn-primary am-btn-sm am-margin-sm" onclick="javascript:window.location.href='${ctx}/index.jsp'"> 返 回 </button>
			    </div>
            </form>
		</div>
			
		<!-- ***** 分离出去 动态加载 end ***** -->
	</div>
	<!-- content end -->
</div>
</div>
</body>

<script type="text/javascript">
function toVaild() {
	var myreg = /^[A-Za-z0-9_]{6,20}$/; 
	if(!myreg.test($("#newPassword").val())) 
	{ 
	    alert('密码格式不正确，请输入6-20位字符（数字，大写字母，小写字母）'); 
	    return false; 
	} 
	
	if($("#newPassword").val() == $("#newPassword2").val()) {
		return true;
	}else {
		alert("新密码输入不一致");
		return false;
	}
}
</script>

</html>